package org.jetnuke.dao.generic;

import org.apache.log4j.Logger;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import net.jforum.JForumExecutionContext;
import net.jforum.dao.generic.AutoKeys;
import net.jforum.util.preferences.SystemGlobals;

import org.jetnuke.entities.LinksLinks;

public class GenericLinkLinkDAO extends AutoKeys implements
		org.jetnuke.dao.LinkLinkDAO {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger
			.getLogger(GenericLinkLinkDAO.class);

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#retrieveByPK(int)
	 */
	public LinksLinks retrieveByPK(int id) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("retrieveByPK(int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectByID"));
		p.setInt(1, id);

		ResultSet rs = p.executeQuery();
		LinksLinks s = new LinksLinks();

		if (rs.next()) {
			fillLinkLinkFromResultSet(s, rs);
		}

		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("retrieveByPK(int) - end"); //$NON-NLS-1$
		}
		return s;
	}

	/**
	 * @param s
	 * @param rs
	 */
	protected void fillLinkLinkFromResultSet(LinksLinks s, ResultSet rs)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger
					.debug("fillLinkLinkFromResultSet(LinksLinks, ResultSet) - start"); //$NON-NLS-1$
		}

		s.setCID(rs.getInt("CID"));
		s.setDATE(rs.getTimestamp("DATE1"));
		s.setDESCRIPTION(rs.getString("DESCRIPTION"));
		s.setLINKRATINGSUMMARY(rs.getDouble("LINKRATINGSUMMARY"));
		s.setEMAIL(rs.getString("EMAIL"));
		// s.setFILESIZE(rs.getInt("FILESIZE"));
		s.setHITS(rs.getInt("HITS"));
		// s.setHOMEPAGE(rs.getString("HOMEPAGE"));
		s.setLID(rs.getInt("LID"));
		s.setNAME(rs.getString("NAME"));
		// s.setSID(rs.getInt("SID"));
		s.setSUBMITTER(rs.getString("SUBMITTER"));
		s.setTITLE(rs.getString("TITLE"));
		s.setTOTALCOMMENTS(rs.getInt("TOTALCOMMENTS"));
		s.setTOTALVOTES(rs.getInt("TOTALVOTES"));
		s.setURL(rs.getString("URL"));
		// s.setVERSION(rs.getString("VERSION"));

		if (logger.isDebugEnabled()) {
			logger
					.debug("fillLinkLinkFromResultSet(LinksLinks, ResultSet) - end"); //$NON-NLS-1$
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectAll()
	 */
	public List selectAll() throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectAll() - start"); //$NON-NLS-1$
		}

		PreparedStatement p;

		p = JForumExecutionContext.getConnection().prepareStatement(
				SystemGlobals.getSql("LinkLinkModel.selectAll"));

		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectAll() - end"); //$NON-NLS-1$
		}
		return list;
	}

	protected List processSelectAll(ResultSet rs) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("processSelectAll(ResultSet) - start"); //$NON-NLS-1$
		}

		List list = new ArrayList();
		while (rs.next()) {
			LinksLinks u = new LinksLinks();
			fillLinkLinkFromResultSet(u, rs);
			list.add(u);
		}

		if (logger.isDebugEnabled()) {
			logger.debug("processSelectAll(ResultSet) - end"); //$NON-NLS-1$
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#addNew(org.jetnuke.entities.DownloadsDownloads)
	 */
	public int addNew(LinksLinks dc) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("addNew(LinksLinks) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = this
				.getStatementForAutoKeys("LinkLinkModel.addNew");
		this.setAutoGeneratedKeysQuery(SystemGlobals
				.getSql("LinkLinkModel.lastGeneratedLinkID"));
		initNewLink(dc, p);

		int id = this.executeAutoKeysQuery(p);
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("addNew(LinksLinks) - end"); //$NON-NLS-1$
		}
		return id;
	}

	/**
	 * @param dc
	 * @param p
	 */
	private void initNewLink(LinksLinks dc, PreparedStatement p)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("initNewLink(LinksLinks, PreparedStatement) - start"); //$NON-NLS-1$
		}

		p.setInt(1, dc.getCID());
		p.setTimestamp(2, new Timestamp(dc.getDATE().getTime()));
		p.setString(3, dc.getDESCRIPTION());
		p.setDouble(4, dc.getLINKRATINGSUMMARY());
		p.setString(5, dc.getEMAIL());
		// p.setInt(6,dc.getFILESIZE());
		p.setInt(6, dc.getHITS());
		// p.setString(8,dc.getHOMEPAGE());

		p.setString(7, dc.getNAME());
		// p.setInt(10,dc.getSID());
		p.setString(8, dc.getSUBMITTER());
		p.setString(9, dc.getTITLE());
		p.setInt(10, dc.getTOTALCOMMENTS());
		p.setInt(11, dc.getTOTALVOTES());
		p.setString(12, dc.getURL());
		// p.setString(16,dc.getVERSION());

		if (logger.isDebugEnabled()) {
			logger.debug("initNewLink(LinksLinks, PreparedStatement) - end"); //$NON-NLS-1$
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#update(org.jetnuke.entities.DownloadsDownloads)
	 */
	public void update(LinksLinks dc) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("update(LinksLinks) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(SystemGlobals.getSql("LinkLinkModel.update"));

		p.setInt(1, dc.getCID());
		p.setTimestamp(2, new Timestamp(dc.getDATE().getTime()));
		p.setString(3, dc.getDESCRIPTION());
		p.setDouble(4, dc.getLINKRATINGSUMMARY());
		p.setString(5, dc.getEMAIL());
		// p.setInt(6,dc.getFILESIZE());
		p.setInt(6, dc.getHITS());
		// p.setString(8,dc.getHOMEPAGE());

		p.setString(7, dc.getNAME());
		// p.setInt(10,dc.getSID());
		p.setString(8, dc.getSUBMITTER());
		p.setString(9, dc.getTITLE());
		p.setInt(10, dc.getTOTALCOMMENTS());
		p.setInt(11, dc.getTOTALVOTES());
		p.setString(12, dc.getURL());
		// p.setString(16,dc.getVERSION());

		p.setInt(13, dc.getLID());
		p.executeUpdate();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("update(LinksLinks) - end"); //$NON-NLS-1$
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#countAll()
	 */
	public int countAll() throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("countAll() - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.countAll"));

		ResultSet rs = p.executeQuery();
		rs.next();
		int r = rs.getInt(1);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("countAll() - end"); //$NON-NLS-1$
		}
		return r;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#incHits(int)
	 */
	public void incHits(int id) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("incHits(int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext
				.getConnection()
				.prepareStatement(SystemGlobals.getSql("LinkLinkModel.incHits"));
		p.setInt(1, id);

		p.executeUpdate();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("incHits(int) - end"); //$NON-NLS-1$
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#countUser(int,
	 *      java.lang.String)
	 */
	public int countUser(int lid, String uname) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("countUser(int, String) - start"); //$NON-NLS-1$
		}

		PreparedStatement p;

		p = JForumExecutionContext.getConnection().prepareStatement(
				SystemGlobals.getSql("LinkLinkModel.countUser"));
		p.setInt(1, lid);
		p.setString(2, uname);
		ResultSet rs = p.executeQuery();
		rs.next();

		int r = rs.getInt(1);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("countUser(int, String) - end"); //$NON-NLS-1$
		}
		return r;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#countAllByCategory(int)
	 */
	public int countAllByCategory(int cid) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("countAllByCategory(int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p;

		p = JForumExecutionContext.getConnection().prepareStatement(
				SystemGlobals.getSql("LinkLinkModel.countByCategory"));
		p.setInt(1, cid);
		ResultSet rs = p.executeQuery();
		rs.next();

		int r = rs.getInt(1);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("countAllByCategory(int) - end"); //$NON-NLS-1$
		}
		return r;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#getByHitsDown(int, int)
	 */
	public List getByHitsDown(int start, int limit) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("getByHitsDown(int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectByHitsDown"));
		p.setInt(1, start);
		p.setInt(2, limit);

		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("getByHitsDown(int, int) - end"); //$NON-NLS-1$
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectDateGreater(java.util.Date)
	 */
	public int selectDateGreater(Date dt) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectDateGreater(Date) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext
				.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectDateGreater"));
		p.setTimestamp(1, new Timestamp(dt.getTime()));

		ResultSet rs = p.executeQuery();
		rs.next();

		int r = rs.getInt(1);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectDateGreater(Date) - end"); //$NON-NLS-1$
		}
		return r;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#countWithRating()
	 */
	public int countWithRating() throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("countWithRating() - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.countWithRating"));

		ResultSet rs = p.executeQuery();
		rs.next();
		int r = rs.getInt(1);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("countWithRating() - end"); //$NON-NLS-1$
		}
		return r;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectWithRating()
	 */
	public List selectWithRating(int totalVotesMin, int limit) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectWithRating(int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectWithRating"));
		p.setInt(1, totalVotesMin);
		p.setInt(2, limit);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectWithRating(int, int) - end"); //$NON-NLS-1$
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectTitleAsc(int, int,
	 *      int)
	 */
	public List selectTitleAsc(int cid, int offset, int rowcount)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectTitleAsc(int, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectTitleAsc"));
		p.setInt(1, cid);
		p.setInt(2, offset);
		p.setInt(3, rowcount);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectTitleAsc(int, int, int) - end"); //$NON-NLS-1$
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectTitleDesc(int, int,
	 *      int)
	 */
	public List selectTitleDesc(int cid, int offset, int rowcount)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectTitleDesc(int, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectTitleDesc"));
		p.setInt(1, cid);
		p.setInt(2, offset);
		p.setInt(3, rowcount);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectTitleDesc(int, int, int) - end"); //$NON-NLS-1$
		}
		return list;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectDateAsc(int, int, int)
	 */
	public List selectDateAsc(int cid, int offset, int rowcount)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectDateAsc(int, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectDateAsc"));
		p.setInt(1, cid);
		p.setInt(2, offset);
		p.setInt(3, rowcount);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectDateAsc(int, int, int) - end"); //$NON-NLS-1$
		}
		return list;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectDateDesc(int, int,
	 *      int)
	 */
	public List selectDateDesc(int cid, int start, int offset) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectDateDesc(int, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectDateDesc"));
		p.setInt(1, cid);
		p.setInt(2, start);
		p.setInt(3, offset);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectDateDesc(int, int, int) - end"); //$NON-NLS-1$
		}
		return list;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectRatingAsc(int, int,
	 *      int)
	 */
	public List selectRatingAsc(int cid, int start, int offset)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectRatingAsc(int, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectRatingAsc"));
		p.setInt(1, cid);
		p.setInt(2, start);
		p.setInt(3, offset);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectRatingAsc(int, int, int) - end"); //$NON-NLS-1$
		}
		return list;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectRatingDesc(int, int,
	 *      int)
	 */
	public List selectRatingDesc(int cid, int start, int offset)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectRatingDesc(int, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectRatingDesc"));
		p.setInt(1, cid);
		p.setInt(2, start);
		p.setInt(3, offset);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectRatingDesc(int, int, int) - end"); //$NON-NLS-1$
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectHitsAsc(int, int, int)
	 */
	public List selectHitsAsc(int cid, int start, int offset) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectHitsAsc(int, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectHitsAsc"));
		p.setInt(1, cid);
		p.setInt(2, start);
		p.setInt(3, offset);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectHitsAsc(int, int, int) - end"); //$NON-NLS-1$
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectHitsDesc(int, int,
	 *      int)
	 */
	public List selectHitsDesc(int cid, int start, int offset) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectHitsDesc(int, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectHitsDesc"));
		p.setInt(1, cid);
		p.setInt(2, start);
		p.setInt(3, offset);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectHitsDesc(int, int, int) - end"); //$NON-NLS-1$
		}
		return list;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.DownloadDownloadModel#selectTopDown(int)
	 */
	public List selectTopDown(int limit) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectTopDown(int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.selectTopDown"));
		p.setInt(1, limit);

		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectTopDown(int) - end"); //$NON-NLS-1$
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.LinkLinkModel#countSearch(java.lang.String,
	 *      java.lang.String)
	 */
	public int countSearch(String title, String description) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("countSearch(String, String) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.countSearch"));
		p.setString(1, title);
		p.setString(2, description);
		ResultSet rs = p.executeQuery();
		rs.next();
		int r = rs.getInt(1);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("countSearch(String, String) - end"); //$NON-NLS-1$
		}
		return r;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.model.LinkLinkModel#search(java.lang.String,
	 *      java.lang.String, int, int)
	 */
	public List search(String title, String description, int offset,
			int rowcount) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("search(String, String, int, int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(SystemGlobals.getSql("LinkLinkModel.search"));
		p.setString(1, title);
		p.setString(2, description);
		p.setInt(3, offset);
		p.setInt(4, rowcount);

		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("search(String, String, int, int) - end"); //$NON-NLS-1$
		}
		return list;
	}

	public void deleteByLID(int lid) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("deleteByLID(int) - start"); //$NON-NLS-1$
		}

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(
						SystemGlobals.getSql("LinkLinkModel.deleteByLID"));

		p.setInt(1, lid);
		p.executeUpdate();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("deleteByLID(int) - end"); //$NON-NLS-1$
		}
	}

}
